// ++++++++++++++++++++++++++++++++++++++++
// 《零基础Go语言算法实战》源码
// ++++++++++++++++++++++++++++++++++++++++
// Author:廖显东（ShirDon）
// Blog:https://www.shirdon.com/
// Gitee:https://gitee.com/shirdonl/goAlgorithms.git
// Buy link :https://item.jd.com/14101229.html
// ++++++++++++++++++++++++++++++++++++++++

package main

import (
	"fmt"
	"time"
)

func FuncOne(num int, out chan<- int) {
	result := num * 3
	time.Sleep(5 * time.Millisecond)
	out <- result

}

func FuncTwo(num int, out chan<- int) {
	result := num * 3
	time.Sleep(15 * time.Millisecond)
	out <- result
}

func main() {
	out1 := make(chan int)
	out2 := make(chan int)

	go FuncOne(6, out1)
	go FuncTwo(8, out2)

	select {
	case res := <-out1:
		fmt.Println("result1:", res)
	case res := <-out2:
		fmt.Println("result2:", res)
	}
}

//$ go run channel3.go
//result1: 18
